<!DOCTYPE html>
<html>
  <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>首页</title>
	
	<link rel="stylesheet" href="../common/layui/css/layui.css">
	<link rel="stylesheet" href="../common/css/sccl.css">
    
  </head>
  
  <body class="login-bg">
    <div class="login-box">
        <header>
            <h1>后台管理系统</h1>
        </header>
        <div class="login-main">
			<div class="layui-form">
				<input name="__RequestVerificationToken" type="hidden" value="">                
				<div class="layui-form-item">
					<label class="login-icon">
						<i class="layui-icon"></i>
					</label>
					<input type="text" id = "userid" name="userName" autocomplete="off" placeholder="这里输入登录名" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="login-icon">
						<i class="layui-icon"></i>
					</label>
					<input type="password" id = "password" name="password" type="password" autocomplete="off" placeholder="这里输入密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<div class="pull-right">
						<button class="layui-btn layui-btn-primary" onclick="tologin()">登录</button>
					</div>
				</div>
				<div id = "ifFailed" style="color:red"></div>
			</div>        
		</div>
      
    </div>
    <script type="text/javascript" src="../common/lib/jquery-1.9.0.min.js"></script>
    <script type="text/javascript">
	function tologin(){
	var userid=$("#userid").val();
	var password=$("#password").val();
	var jo = {
		"userid":userid,
		"password":password,
		"status":"admin"
	};

	$.ajax({
		type : "post",
		url : "../login.action",
		dataType : "json",
		data : jo,
		success : function(data) {
			if(data.status=="succeed"){
				location.href="ad_index.html";
				return true;
			}else if(data.status=="fail"){
				var div = document.getElementById('ifFailed');
				var label = document.createElement('label');
				label.innerHTML='请确认用户名与密码是否正确！';
				div.appendChild(label);
				return false;
			}
			
			
		}
	});	 
}
</script>

  </body>
</html>
